package cn.xxi.ai.application.dto;

import cn.xxi.ai.application.entity.MessageData;
import cn.xxi.ai.util.JsonUtil;
import dev.langchain4j.service.tool.ToolExecution;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Map;

@Data
@AllArgsConstructor
public class ToolExecuted extends MessageData {
    private String name;
    private Map<String, Object> arguments;
    private String result;

    public ToolExecuted(ToolExecution toolExecution) {
        this(
            toolExecution.request().name(),
            JsonUtil.toMap(toolExecution.request().arguments()),
            toolExecution.result()
        );
    }
}
